<%@page import="com.pay.caihong.server.MD5"%>
<%@page import="com.jsp.payment.service.PaymentService"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.vo.Gateway"%>
<%@page import="java.math.BigDecimal"%>
<%@page import="org.dom4j.Document"%>
<%@page import="org.dom4j.DocumentHelper"%>
<%@page import="org.dom4j.Element"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
	String orderid = request.getParameter("orderid");
	String opstate = request.getParameter("opstate");
	String ovalue = request.getParameter("ovalue");
	String systime = request.getParameter("systime");
	String sysorderid = request.getParameter("sysorderid");
	String completiontime = request.getParameter("completiontime");
	String attach = request.getParameter("attach");
	String msg = request.getParameter("msg");
	String sign = request.getParameter("sign");
	Gateway gateway = Gateway.dao.findById(17);
	String MD5key = gateway.getStr("gateway_key");
	String md5Str = "orderid=" + orderid + "&opstate=" + opstate + "&ovalue=" + ovalue + MD5key;
	MD5 md5 = new MD5();
	String MD5info = md5.getMD5ofStr(md5Str).toLowerCase();
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	if(MD5info.equals(sign)){
		if(opstate.equals("0")){
				PaymentService.service.netcallback("", orderid, "", sdf.format(new Date()), sdf.format(new Date()));
				response.sendRedirect(basePath+"/payment/showPayOk");
			} else {
				PaymentService.service.failure(orderid, sdf.format(new Date()));
				response.sendRedirect(basePath+"/payment/showPayNo");
			}
	} else {
		out.println("交易签名被篡改!");
	}
%>